﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Net;
using System.IO;
using System.Xml.Linq;
using HtmlAgilityPack;  

namespace ParsowanieAkcje
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }


        public static String getFromWebSite(String url)
        {
            WebRequest request = WebRequest.Create(url.Trim());
            WebResponse response = request.GetResponse();
            Stream data = response.GetResponseStream();
            string html = String.Empty;
            using (StreamReader sr = new StreamReader(data))
            {
                html = sr.ReadToEnd();
            }

            return html;
        }



        private void buttonGet_Click(object sender, EventArgs e)
        {
            String path = @"d:\Studia_V_rok\Semestr_III\Platformy_mobilne\testData\test1.txt";

            List<SecurityIndice> listSecurityIndice = HtmlSecurityParser.getFromFile(getFromWebSite(textBoxUrl.Text));

            foreach (var item in listSecurityIndice)
            {
                textBoxContent.Text += item.Security.SecurityName
                + "  " +item.Security.SecurityCode
                + "  " +item.Rate
                +Environment.NewLine + Environment.NewLine;
 
            }

        }
    }
}
